#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string>
#include "common.hpp"
#include <unistd.h>
int main()
{
    umask(0);
    int n = mkfifo(FIFO_FILE,0666);
    if(n != 0)
    {
         std::cout << "mkfifo error" << std::endl;
        return 1;
    }
    int fd = open(FIFO_FILE,O_RDONLY);
    if(fd < 0) 
    {
        std::cout << "open error" << std::endl;
        return 1;
    }
    char buffer[1024];
    while(true)
    {
        int n = read(fd,buffer,sizeof(buffer)-1);
        if(n)
        {
            buffer[n] = 0;
            std::cout << "The Client say:" << buffer << std::endl;
        }
    }
    close(fd);

    return 0;
}